import sys
from PyQt5.QtWidgets import QApplication, QWidget, QPushButton, QHBoxLayout, QRadioButton
from PyQt5.QtCore import pyqtSlot

def on_toggle_nan(arg):
    print("男选中:", arg)
def on_toggle_nv(arg):
    print("女选中:", arg)
def on_toggle_yao(arg):
    print("妖选中:", arg)
    
def init_weiget(w:QWidget):
    w.setWindowTitle("单选框")
    # w.resize(680, 480)
    layout = QHBoxLayout()
    w.setLayout(layout)
    
    btn1 = QRadioButton("男")
    btn2 = QRadioButton("女")
    btn3 = QRadioButton("妖")
    btn3.setChecked(True)
    
    btn1.toggled.connect(on_toggle_nan)
    btn2.toggled.connect(on_toggle_nv)
    btn3.toggled.connect(on_toggle_yao)
    
    layout.addWidget(btn1)
    layout.addWidget(btn2)
    layout.addWidget(btn3)
    
if __name__ == '__main__':
    app = QApplication(sys.argv)
    w  = QWidget()
    init_weiget(w)
    w.show()
    sys.exit(app.exec_())
